﻿using System.Diagnostics;
using System.ComponentModel;

namespace MyWindowsMediaPlayer.Libs.ViewModel
{
	public abstract class ViewModelBase : INotifyPropertyChanged
	 {
        public event PropertyChangedEventHandler PropertyChanged;

        [Conditional("DEBUG")]
        [DebuggerStepThrough]
        public void VerifyPropertyName(string propertyname)
        {
            if (TypeDescriptor.GetProperties(this) == null)
            {
                Debug.Fail("Invalid property name: " + propertyname);
            }
        }

        protected virtual void OnPropertyChanged(string propertyName)
        {
            this.VerifyPropertyName(propertyName);

            if (this.PropertyChanged != null)
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
